﻿<div class="modal fade" id="myModal_ModifyGoodsSortName" tabindex="-100" role="dialog" data-backdrop="static" aria-labelledby="myModalModifyGoodsSortName" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h5 class="modal-title" id="myModalLabel_AddGordsSort"><span class="glyphicon glyphicon-pencil text-danger"></span>修改<span class="label label-danger"> @ViewData["GoodsSortName"]</span> 名字</h5>
            </div>
            <div class="modal-body">
                <form action="#">
                    <div class="form-group">
                        <label for="addname">大类名称更改为:</label>
                        <input type="text" name="GoodsSortName" class="form-control" placeholder="大类名称">

                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <span class="text-danger" style="display:none">输入商品分类不能为空</span>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="btn_ModifyGoodsSortName">提交</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    $(function () {
        $('#myModal_ModifyGoodsSortName form').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                GoodsSortName: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '大类名不能为空！'
                        }
                    }
                }
            }
        });
    });
</script>
<script type="text/javascript">
    //模态框关闭之后触发
    $("#myModal_ModifyGoodsSortName").on('hidden.bs.modal', function (e) {

        // $(this).removeData("bs.modal");
        //$('#myModal_EditGords form').data('bootstrapValidator').resetForm(true);
        $("#Pannel_Goodslist").load('Admin/GoodssByTeamID/' + '@ViewData["GoodsSortID"]');
    });
    $('#myModal_EditGords').on('show.bs.modal', function (e) {

        $("#myModal_ModifyGoodsSortName .modal-footer>span").html("");
    })
    //提交的ajax
    $("#myModal_ModifyGoodsSortName form").submit(function (ev) { ev.preventDefault(); });
    $("#btn_ModifyGoodsSortName").on("click", function () {

        var bootstrapValidator = $('#myModal_ModifyGoodsSortName  form').data('bootstrapValidator');
        bootstrapValidator.validate();
        if (bootstrapValidator.isValid()) {
            $.ajax({
                type: 'POST',
                data: "GoodsSortName=" + $("#myModal_ModifyGoodsSortName").find("input[name='GoodsSortName']").val()
                +"&GoodsSortID="+'@ViewData["GoodsSortID"]',
                url: 'Admin/btn_ModifyGoodsSortName',
                success: function (data) {

                    if (data == "ok") {
                        //$("#myModal_AddGords").modal("hide");
                        //刷新下拉菜单绑定的商品分类

                        //增加添加成功信息

                        $("#myModal_ModifyGoodsSortName .modal-footer").find("span").show().html("修改成功！");
                        //刷新下拉菜单绑定的商品分类
                        $("#GoodsSortList").load('Admin/AdminGoods');
                       
                    }
                    else { alert("没有成功"); }

                },
                error: function (error) {
                    alert(error.responseText);
                }
            });
        }
        else return;

    });
</script>